
clear
set more off

use "E:\Cuong - paper\COVID\do-files\PLOS ONE\Data final.dta", clear

	* Table A.1
	tab gender country, nof col
	
	tab age_group country, nof col

	* Table A.2
	tab income_group country, nof col
	
	drop if income_group==.
	recode income_group 6=.	

	gen caserate=confirmed/(1000*population)
	
* Ouctome variables
	* drop if gender==3
	gen female=(gender==2)
	
	recode race_black -99=.
	
	for var lost_hh_income expected_fall_own_lab expected_fall_hh_inc: replace X=0 if X<0
	gen double lnlostinc= log(lost_hh_income+ 1)
	gen double lnexpowninc= log(expected_fall_own_lab+ 1)
	gen double lnexphhinc= log(expected_fall_hh_inc+ 1)

	gen workwell=work_from_home_well
	
	gen workchange=0 if work_change_due_pandemic>=1 & work_change_due_pandemic<=3
	replace workchange=1 if work_change_due_pandemic>=1 & work_change_due_pandemic<=2
	tab workchange
	
	gen dinloss=(experienced_fall_hh_income==1)

	gen lost_job0=(lost_job==1 | lost_job==2)
	gen lost_job1=(lost_job==1)
	gen lost_job2=(lost_job==2)
	* for var lost_job0 lost_job1 lost_job2 workwell workchange lnexpowninc : replace X=. if labor_status==4
	
	gen happy=(happiness_these_days>=5)
	gen veryhappy=(happiness_these_days>=6)
	gen unhappy=(happiness_these_days<=2)
	
	tab change_weekly_expenses female , nof col
	
	tab change_savings female , nof col
	
	 gen gov=(industry==8)
	
* Control variables
	drop if income_group==.
	recode income_group 6=.	
	gen qt1= income_group== 1 if income_group<.
	gen qt2= income_group== 2 if income_group<.
	gen qt3= income_group== 3 if income_group<.
	gen qt4= income_group== 4 if income_group<.
	gen qt5= income_group== 5 if income_group<.

	gen exposure_ms= exposure== .

	recode age_group 8=4
	ta age_group, gen(ageg)
	gen urban= current_living_area== 1 
	gen surban= current_living_area== 2
	gen rural= current_living_area== 3

	gen china= country== "china"
	gen italy= country== "italy"
	gen japan= country== "japan"
	gen korea= country== "korea"
	gen uk= country== "uk"
	gen us= country== "us"

	gen group=1 if country== "china"
	replace group=2 if country== "japan"
	replace group=3 if  country== "korea"
	replace group=4 if country== "italy"
	replace group=5 if country== "uk"
	replace group=6 if country== "us"
	
	
	gen gini=40.9 if country== "china"
	replace gini=25.6 if country== "japan"
	replace gini=32.7 if  country== "korea"
	replace gini=33.7 if country== "italy"
	replace gini=33.3 if country== "uk"
	replace gini=38.2 if country== "us"
	
	
	gen gini1=38.5 if country== "china"
	replace gini1=32.9 if country== "japan"
	replace gini1=31.6 if  country== "korea"
	replace gini1=35.9 if country== "italy"
	replace gini1=34.8 if country== "uk"
	replace gini1=41.4 if country== "us"
	
	gen gdp=10261.7 if country== "china"
	replace gdp=40246.9 if country== "japan"
	replace gdp=31846.2 if  country== "korea"
	replace gdp=33228.2 if country== "italy"
	replace gdp=42330.1 if country== "uk"
	replace gdp=65297.5 if country== "us"
	
	gen secondary=4.3 if country== "china"
	replace secondary=80.3 if country== "japan"
	replace secondary=76.4 if  country== "korea"
	replace secondary=49.2 if country== "italy"
	replace secondary=77.1 if country== "uk"
	replace secondary=89.8 if country== "us"
	
	
	gen unemp=4.3 if country== "china"
	replace unemp=2.3 if country== "japan"
	replace unemp=4.1 if  country== "korea"
	replace unemp=9.8 if country== "italy"
	replace unemp=3.9 if country== "uk"
	replace unemp=3.8 if country== "us"
	
	gen ratio10=highest10/lowest10 
	gen ratio20=highest20/lowest20
	
	for var qt1 qt2 qt3 qt4 qt5: gen X_gini=X*gini
	for var qt1 qt2 qt3 qt4 qt5: gen X_ratio10=X*ratio10
	for var qt1 qt2 qt3 qt4 qt5: gen X_ratio20=X*ratio20
	for var qt1 qt2 qt3 qt4 qt5: gen X_caserate=X*caserate
	
	
	egen cluster=group(region country)
	
	gen self_employed=(labor_status==3)
	gen employed=(labor_status==1)
	gen part_employed=(labor_status==2)
	
	gen house=(current_home==1)
	gen apartment=(current_home==2)
	
	gen alone=(current_living_arrangement==1 | current_living_arrangement==5)
	
	recode industry .=0

	gen asia=(country=="china" | country=="japan" | country=="korea")
	tab asia

	gen female_asia = female*asia
	
	gen expendrop=(change_weekly_expenses<=2)
	gen savingrop=(change_savings<=2)
	
	* Variables means.
	for var lost_job1 lost_job2 expendrop savingrop: gen X100=X*100

	tabform lost_job1100 lost_job2100 lnlostinc lnexpowninc change_weekly_expenses change_savings expendrop100 savingrop100 using E:\covid.xls, by(female)  se vertical
	
	
	* Regression
	global demo "belief_you_got_infected belief_infected_yourarea  alone ageg2-ageg7 urban"
	global country "china italy japan korea uk self_employed employed part_employed"
	
	global demo "ageg2 ageg3 ageg4 ageg5 ageg6 ageg7 urban"
	global country "china japan korea italy uk"
	* global country " female_asia asia"

	for var belief_policy_effectiveness_1 belief_policy_effectiveness_2 belief_policy_effectiveness_3 ///
		belief_policy_effectiveness_4 belief_policy_effectiveness_5 belief_policy_effectiveness_6 belief_policy_effectiveness_7 agree_government_action: gen nX=(X<=2)
	
	for var belief_policy_effectiveness_1 belief_policy_effectiveness_2 belief_policy_effectiveness_3 ///
		belief_policy_effectiveness_4 belief_policy_effectiveness_5 belief_policy_effectiveness_6 belief_policy_effectiveness_7 agree_government_action: gen dX=(X>=4)
	
	* Index
	pca belief_policy_effectiveness_1 belief_policy_effectiveness_2 belief_policy_effectiveness_3 ///
		belief_policy_effectiveness_4 belief_policy_effectiveness_5 belief_policy_effectiveness_6 belief_policy_effectiveness_7, com(1) vce(norm) ignore
	predict index

	sum index
	replace index=(index-r(mean))/r(sd)
	sum index
	
* Descriptive analysis
* Table A.3
	
	tab1 belief_policy_effectiveness_1 belief_policy_effectiveness_2 belief_policy_effectiveness_3 ///
		belief_policy_effectiveness_4 belief_policy_effectiveness_5 belief_policy_effectiveness_6 belief_policy_effectiveness_7 agree_government_action
		
	sum dbelief_policy_effectiveness_1 dbelief_policy_effectiveness_2 dbelief_policy_effectiveness_3 ///
		dbelief_policy_effectiveness_4 dbelief_policy_effectiveness_5 dbelief_policy_effectiveness_6 dbelief_policy_effectiveness_7 dagree_government_action 
	
	sum belief_policy_effectiveness_1 belief_policy_effectiveness_2 belief_policy_effectiveness_3 ///
		belief_policy_effectiveness_4 belief_policy_effectiveness_5 belief_policy_effectiveness_6 belief_policy_effectiveness_7 agree_government_action 
	
	
* Table A.4
	table country, c(mean gini mean caserate mean agree_government_action mean  belief_policy_effectiveness_1 mean belief_policy_effectiveness_2) row col format(%5.2f)
	table country, c(mean ratio10 mean ratio20) row col format(%5.2f)
	
	table country, c(mean belief_policy_effectiveness_3 mean belief_policy_effectiveness_4 mean belief_policy_effectiveness_5 mean belief_policy_effectiveness_6 ///
		mean belief_policy_effectiveness_7) row col format(%5.2f)
	
	* Regresssion here
	reg belief_policy_effectiveness_1 caserate female $demo qt1 qt2 qt3 qt4 $country, robust
		outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr replace nolabel 
		
	
********** OLS *****************
* Table A.5. OLS regressions of belief that government’s policy to the COVID-19 pandemic was effective

	foreach var in agree_government_action belief_policy_effectiveness_1 belief_policy_effectiveness_2 belief_policy_effectiveness_3 ///
		belief_policy_effectiveness_4 belief_policy_effectiveness_5 belief_policy_effectiveness_6 belief_policy_effectiveness_7 {	
		reg `var' caserate female $demo qt1 qt2 qt3 qt4 $country, robust
		outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}

	* with control variables
	gen black=(race_black==1) 
	gen white=(race_white ==1)
	

* Table A.6. Regression of variable ‘believe in the government in response to the pandemic’ for different countries
	* By country
	local i=1
	
	while `i'<=6 {
	
	foreach var in index agree_government_action {	
		
		
		reg `var' caserate female $demo qt1 qt2 qt3 qt4 if group==`i', robust
		
			outreg2 using E:\governance_country.xls, se bdec(4) sdec(4) coefastr append nolabel 
		
		}
		
		local i=`i'+1
	}
	
* Table A.7: OLS regressions with interactions
	foreach var in agree_government_action index {
			reg `var' caserate female $demo qt1 qt2 qt3 qt4 qt1_gini qt2_gini qt3_gini qt4_gini $country, robust 
			outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
	
* Table A.8. Regression of variable ‘believe in the government in response to the pandemic’ 
		* and Index of the variables 'believe to different policies' with interactions 

	gen highskill=(industry==15 | industry==11 | industry==8)
	gen tourism=(industry==1 | industry==18)
	gen service=(industry==6 | industry==7 | industry==9 | industry==10 | industry==16)
	gen manufac=(industry==12 | industry==13 | industry==5)
	gen trade=(industry==17 | industry==20)

	for var qt1 qt2 qt3 qt4 qt5: gen X_highskill=X*highskill
	for var qt1 qt2 qt3 qt4 qt5: gen X_service=X*service
	for var qt1 qt2 qt3 qt4 qt5: gen X_manufac=X*manufac
	for var qt1 qt2 qt3 qt4 qt5: gen X_trade=X*trade
	for var qt1 qt2 qt3 qt4 qt5: gen X_tourism=X*tourism
	
	
	foreach var in agree_government_action index {
			reg `var' caserate female $demo qt1 qt2 qt3 qt4 qt1_highskill qt2_highskill qt3_highskill qt4_highskill $country i.industry, robust 
			outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
	foreach var in agree_government_action index {
			reg `var' caserate female $demo qt1 qt2 qt3 qt4 qt1_service qt2_service qt3_service qt4_service $country i.industry, robust 
			outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
	foreach var in agree_government_action index {
			reg `var' caserate female $demo qt1 qt2 qt3 qt4 qt1_manufac qt2_manufac qt3_manufac qt4_manufac $country i.industry, robust 
			outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
	
	foreach var in agree_government_action index {
			reg `var' caserate female $demo qt1 qt2 qt3 qt4 qt1_tourism qt2_tourism qt3_tourism qt4_tourism $country i.industry, robust 
			outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
	foreach var in agree_government_action index {
			reg `var' caserate female $demo qt1 qt2 qt3 qt4 qt1_trade qt2_trade qt3_trade qt4_trade $country i.industry, robust 
			outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
* Mechanisms
* Table A.9. OLS regression of mediating variables on income quintiles
	
	foreach var in lost_job1 lost_job2 change_weekly_expenses change_savings ///
		pos_nonfin_freetime pos_nonfin_lesspolution neg_nonfin_troublesleep neg_nonfin_boredom neg_nonfin_conflicts {	
		reg `var' caserate female $demo qt1 qt2 qt3 qt4 $country, robust
		outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
* Table A.10. OLS regression of 'Believe in the approach of the government in response to the pandemic' on mediating variables
	
	foreach var in lost_job1 lost_job2 change_weekly_expenses change_savings ///
		pos_nonfin_freetime pos_nonfin_lesspolution neg_nonfin_troublesleep neg_nonfin_boredom neg_nonfin_conflicts {	
		reg agree_government_action `var' caserate female $demo qt1 qt2 qt3 qt4 $country, robust
		outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
	* Mediation analysis
	
	foreach var in lost_job1 lost_job2 change_weekly_expenses change_savings ///
		pos_nonfin_freetime pos_nonfin_lesspolution neg_nonfin_troublesleep neg_nonfin_boredom neg_nonfin_conflicts {	
		
		medeff (regress `var' caserate female $demo qt1 qt2 qt3 qt4 $country)  ///
			(regress  agree_government_action `var' caserate female $demo qt1 qt2 qt3 qt4 $country), mediate(`var') treat(qt1) vce(robust)
	
	} 	
	
	
	
	
* TABLE B1: Order logit: report odd ratio
	foreach var in belief_policy_effectiveness_1 belief_policy_effectiveness_2 belief_policy_effectiveness_3 ///
		belief_policy_effectiveness_4 belief_policy_effectiveness_5 belief_policy_effectiveness_6 belief_policy_effectiveness_7 agree_government_action  {	
		ologit `var' caserate female $demo qt1 qt2 qt3 qt4 $country, robust or
		outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel  eform  cti(odds ratio) addstat(R-squared, e(r2_p))
	}
	
	* Get P-value
	foreach var in belief_policy_effectiveness_1 belief_policy_effectiveness_2 belief_policy_effectiveness_3 ///
		belief_policy_effectiveness_4 belief_policy_effectiveness_5 belief_policy_effectiveness_6 belief_policy_effectiveness_7 agree_government_action  {	
		ologit `var' caserate female $demo qt1 qt2 qt3 qt4 $country, robust or
		outreg2 using E:\governance_pvalue.xls, pvalue bdec(4) pdec(5) coefastr append nolabel 
	}
	
* Table B2. OLS regressions with interactions		
	* Bottom quintile
	gen qt12=(qt1==1 | qt2==1)
	gen qt123=(qt1==1 | qt2==1 | qt3==1)
	gen qt1234=(qt1==1 | qt2==1 | qt3==1 | qt4==1)
	
	for var qt12 qt123 qt1234: gen X_gini=X*gini
	
	
	foreach var in agree_government_action index {
		reg `var' caserate female $demo qt1 qt1_gini $country, robust 
			outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
			
		reg `var' caserate female $demo qt12 qt12_gini $country, robust 
			outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
* Table B.3.  OLS regressions with interactions between income quintiles and ratio of income percentiles
	foreach var in agree_government_action index {	
		reg `var' caserate female $demo qt1 qt2 qt3 qt4 qt1_ratio10 qt2_ratio10 qt3_ratio10 qt4_ratio10 $country, robust
		outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
	foreach var in agree_government_action index {	
		reg `var' caserate female $demo qt1 qt2 qt3 qt4 qt1_ratio20 qt2_ratio20 qt3_ratio20 qt4_ratio20 $country, robust
		outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
		

* Table B4. OLS regressions of agreement with government’s responses to the COVID-19 pandemic with controlling for additional individual-level observable variables	
	foreach var in agree_government_action belief_policy_effectiveness_1 belief_policy_effectiveness_2 belief_policy_effectiveness_3 ///
		belief_policy_effectiveness_4 belief_policy_effectiveness_5 belief_policy_effectiveness_6 belief_policy_effectiveness_7 {	
		reg `var' caserate female $demo qt1 qt2 qt3 qt4 $country i.current_home i.industry, robust
		outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
	
	foreach var in agree_government_action belief_policy_effectiveness_1 belief_policy_effectiveness_2 belief_policy_effectiveness_3 ///
		belief_policy_effectiveness_4 belief_policy_effectiveness_5 belief_policy_effectiveness_6 belief_policy_effectiveness_7 {	
		reg `var' caserate female white black $demo qt1 qt2 qt3 qt4 $country i.current_home i.industry, robust
		outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	
	
* Table B5. OLS regressions of agreement with government’s responses to the COVID-19 pandemic with controlling for country-level observable variables	
	* with control variables
	gen lngdp=ln(gdp)
	foreach var in agree_government_action belief_policy_effectiveness_1 belief_policy_effectiveness_2 belief_policy_effectiveness_3 ///
		belief_policy_effectiveness_4 belief_policy_effectiveness_5 belief_policy_effectiveness_6 belief_policy_effectiveness_7 {	
		reg `var' caserate female $demo qt1 qt2 qt3 qt4 lngdp gini unemp second, robust
		outreg2 using E:\governance.xls, se bdec(4) sdec(4) coefastr append nolabel 
	}
	

	
	log close
	

